package com.ruoyi.law.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.law.domain.ContentCustomStep;
import com.ruoyi.law.service.IContentCustomStepService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 自定义内容 步骤Controller
 * 
 * @author ruoyi
 * @date 2025-02-25
 */
@RestController
@RequestMapping("/system/step")
public class ContentCustomStepController extends BaseController
{
    @Autowired
    private IContentCustomStepService contentCustomStepService;

    /**
     * 查询自定义内容 步骤列表
     */
    @PreAuthorize("@ss.hasPermi('system:step:list')")
    @GetMapping("/list")
    public TableDataInfo list(ContentCustomStep contentCustomStep)
    {
        startPage();
        List<ContentCustomStep> list = contentCustomStepService.selectContentCustomStepList(contentCustomStep);
        return getDataTable(list);
    }
    /**
     * 查询自定义内容 步骤列表
     */
    @PreAuthorize("@ss.hasPermi('system:step:diyList')")
    @GetMapping("/diyList")
    public TableDataInfo diyList(ContentCustomStep contentCustomStep)
    {
        startPage();
        List<ContentCustomStep> list = contentCustomStepService.selectContentCustomStepList(contentCustomStep);
        return getDataTable(list);
    }

    /**
     * 导出自定义内容 步骤列表
     */
    @PreAuthorize("@ss.hasPermi('system:step:export')")
    @Log(title = "自定义内容 步骤", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ContentCustomStep contentCustomStep)
    {
        List<ContentCustomStep> list = contentCustomStepService.selectContentCustomStepList(contentCustomStep);
        ExcelUtil<ContentCustomStep> util = new ExcelUtil<ContentCustomStep>(ContentCustomStep.class);
        util.exportExcel(response, list, "自定义内容 步骤数据");
    }

    /**
     * 获取自定义内容 步骤详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:step:query')")
    @GetMapping(value = "/{formId}")
    public AjaxResult getInfo(@PathVariable("formId") Long formId)
    {
        return success(contentCustomStepService.selectContentCustomStepByFormId(formId));
    }

    /**
     * 新增自定义内容 步骤
     */
    @PreAuthorize("@ss.hasPermi('system:step:add')")
    @Log(title = "自定义内容 步骤", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ContentCustomStep contentCustomStep)
    {
        return toAjax(contentCustomStepService.insertContentCustomStep(contentCustomStep));
    }

    /**
     * 修改自定义内容 步骤
     */
    @PreAuthorize("@ss.hasPermi('system:step:edit')")
    @Log(title = "自定义内容 步骤", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ContentCustomStep contentCustomStep)
    {
        return toAjax(contentCustomStepService.updateContentCustomStep(contentCustomStep));
    }

    /**
     * 删除自定义内容 步骤
     */
    @PreAuthorize("@ss.hasPermi('system:step:remove')")
    @Log(title = "自定义内容 步骤", businessType = BusinessType.DELETE)
	@DeleteMapping("/{formIds}")
    public AjaxResult remove(@PathVariable Long[] formIds)
    {
        return toAjax(contentCustomStepService.deleteContentCustomStepByFormIds(formIds));
    }
}
